package com.example.springboot.mapper;

import com.example.springboot.entity.Wine;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WineMapper {

    @Insert("insert into sys_wine (name, chateau, kind, place, materials, taste) VALUES (#{name},#{chateau},#{kind},#{place},#{materials},#{taste})")
    void insert(Wine wine);

    @Update("update sys_wine set name = #{name},chateau = #{chateau}, kind = #{kind}, place = #{place}, materials = #{materials}, taste = #{taste} where id = #{id}")
    void updateWine(Wine wine);

    @Delete("delete from sys_wine where id = #{id}")
    void deleteWine(Integer id);

    @Select("select * from sys_wine order by id desc ")
    List<Wine> selectAll();

    @Select("select * from sys_wine where id = #{id} order by id desc")
    Wine selectById(Integer id);

    @Select("select * from sys_wine where name = #{name} order by id desc;")
    List<Wine> selectByName(String name);
}
